/**
 * Communication Manager
 * This class handles client side calls to the server, and receives response.
 * Relays messages from UI to system and back via RPC protocol.
 * 
 * It is NOT part of the official RPC interface stuff, its just another level of abstraction to implement
 * MVC design pattern
 * TODO how do we instantiate system?
 */
package ocrs.client;
import java.io.Serializable;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

import ocrs.server.registeringSystem.OdinsFistSystem;
import ocrs.server.registeringSystem.User;
import ocrs.server.registeringSystem.Course;


/**
 * @author Jasmine Jones
 *
 */
public class MiddleMan {

//	private static RPCInterfaceAsync rpcservice = GWT.create(RPCInterface.class);
//
//	private static boolean valid = false; //pass info from callback to UI
//	private static final int permission = 0; //default
//	//public static User currentUser;
//	
//	public MiddleMan(){
//	}
//	
//	
//	public static void initProxyServer()
//	{
//		//initialize service proxy
//		if(rpcservice == null)
//		{ rpcservice = GWT.create(RPCInterface.class);}
//	}
//	/**
//	 * LoginUser (static)
//	 * communicate to server user's login info.
//	 * @param login
//	 * @param password
//	 * @return true if login successful
//	 */
//	public static boolean loginUser(String login, String password )
//	{
//		//reset valid
//		valid = false;
//		
//		//setup server & callback
//		initProxyServer();
//		
//		AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>()
//		{
//			public void onFailure(Throwable caught)
//			{
//				Window.alert("Failed:" + caught.getMessage());
//			}
//
//			//this method gives result of service
//			public void onSuccess(Boolean result)
//			{
//				Window.alert((result ? "Login Successful" : "Login failed"));
//				MiddleMan.validate(result);
//			}
//		};
//		
//		//invoke the service (ie the call the method on the server side- RPCServiceImpl)
//		rpcservice.loginUser(login, password, callback);
//		
//		//let UI know if login successful
//		return valid;
//	}
//	public static boolean validate(Boolean bool){ return valid = bool;}
//	
//	
	
}


